class CommonChoice {
    constructor() {
    }
    CommonChoice(w, h, title, url, callback) {
        showModal(w, h, title, parent.basePath + url, null, ($dialog) => {
            let _exist = $.inArray($dialog, parent.arrDialog);
            if (_exist >= 0) {
                parent.arrDialog.splice($.inArray($dialog, parent.arrDialog), 1);
            }
            // 选择设置
            if (parent.choice_success) {
                callback(parent.arrChoice[0]);
            } else {
                callback(false);
            }
            // 清空数组
            parent.arrChoice.splice(0, parent.arrChoice.length);
            parent.choice_success = false;
        });
    }
    // 选择客户
    DoChoiceCustomer(params, title, callback) {
        let arg = window.btoa(window.encodeURI(JSON.stringify(params)));
        this.CommonChoice(1095, 538, title, '/master/customer/choice.html?params=' + arg, callback);
    }
    // 选择供应商
    DoChoiceSupplier(params, title, callback) {
        let arg = window.btoa(window.encodeURI(JSON.stringify(params)));
        this.CommonChoice(1095, 538, title, '/master/supplier/choice.html?params=' + arg, callback);
    }
    // 选择供应商分组
    DoChoiceSupplierGroup(flag, title, callback) {
        this.CommonChoice(1095, 538, title, '/master/supplier_group/choice.html?flag=' + flag, callback);
    }
    // 选择用户
    DoChoiceUser(flag, title, dept, callback) {
        if (dept === null) {
            this.CommonChoice(1095, 538, title, '/master/employee/choice.html?flag=' + flag, callback);
        } else {
            this.CommonChoice(1095, 538, title, '/master/employee/choice.html?flag=' + flag + '&dept=' + dept, callback);
        }
    }
    // 选择本公司
    DoChoiceEnterprise(flag, title, callback) {
        this.CommonChoice(1095, 538, title, '/master/enterprise/choice.html?flag=' + flag, callback);
    }
    // 选择用户组成员
    DoChoiceUserGroupMember(flag, title, callback) {
        this.CommonChoice(1095, 538, title, '/master/user_group/member/choice.html?flag=' + flag, callback);
    }
    // 选择运输方式
    DoChoiceShippingType(flag, callback) {
        this.CommonChoice(695, 438, '选择运输方式', '/master/shipping_type/choice.html?flag=' + flag, callback);
    }
    // 选择贸易方式
    DoChoiceTradeMode(flag, callback) {
        this.CommonChoice(695, 438, '选择贸易方式', '/master/trade_mode/choice.html?flag=' + flag, callback);
    }
    DoChoiceSettlementMode(flag, callback) {
        this.CommonChoice(895, 438, '选择结算方式', '/master/settlement_mode/choice.html?flag=' + flag, callback);
    }
    // 选择币种
    DoChoiceCurrency(flag, callback) {
        this.CommonChoice(695, 438, '选择币种', '/master/currency/choice.html?flag=' + flag, callback);
    }
    DoChoiceTaxRate(flag, callback) {
        this.CommonChoice(695, 438, '选择税率', '/master/tax_rate/choice.html?flag=' + flag, callback);
    }
    // 选择计量单位
    DoChoiceUom(flag, title, callback) {
        this.CommonChoice(585, 478, title, '/master/uom/choice.html?flag=' + flag, callback);
    }
    // 选择产品季节
    DoChoiceSeason(flag, title, callback) {
        this.CommonChoice(585, 438, title, '/master/season/choice.html?flag=' + flag, callback);
    }
    // 选择产品品类
    DoChoiceProductType(flag, title, callback) {
        this.CommonChoice(1095, 538, title, '/master/product_type/choice.html?flag=' + flag, callback);
    }
    // 选择终端客户
    DoChoiceEndUser(flag, title, callback) {
        this.CommonChoice(1095, 538, title, '/master/enduser/choice.html?flag=' + flag, callback);
    }
    // 选择产品
    DoChoiceProduct(flag, title, callback) {
        this.CommonChoice(1095, 538, title, '/master/product/choice.html?flag=' + flag, callback);
    }
    // 选择颜色
    DoChoiceColour(flag, callback) {
        this.CommonChoice(1095, 538, '选择颜色', '/master/colour/choice.html?flag=' + flag, callback);
    }
    // 选择尺码
    DoChoiceSize(flag, callback) {
        this.CommonChoice(1095, 538, '选择尺码', '/master/size/choice.html?flag=' + flag, callback);
    }
    // 选择材料订货损耗及到货允许类型
    DoChoiceToleranceType(flag, title, callback) {
        this.CommonChoice(1095, 538, title, '/master/material_tolerance_type/choice.html?flag=' + flag, callback);
    }
    // 选择许可数量
    DoChoiceQuantityOfLimited(flag, title, callback) {
        this.CommonChoice(1095, 538, title, '/master/quantity_of_limited/choice.html?flag=' + flag, callback);
    }
    // 选择质量标准
    DoChoiceInpStandard(flag, title, callback) {
        this.CommonChoice(1095, 538, title, '/master/inpstandard/choice.html?flag=' + flag, callback);
    }
    // 选择发货地址
    DoChoiceDeliveryAddress(flag, title, callback) {
        this.CommonChoice(1095, 538, title, '/master/delivery_address/choice.html?flag=' + flag, callback);
    }
    // 选择材料分组
    DoChoiceMaterialGroup(flag, title, callback) {
        this.CommonChoice(1095, 538, title, '/master/material_group/choice.html?flag=' + flag, callback);
    }
    // 选择材料备料来源类型
    DoChoiceMaterialSourceType(flag, title, callback) {
        this.CommonChoice(895, 438, title, '/master/material_source_type/choice.html?flag=' + flag, callback);
    }
    // 选择材料
    DoChoiceMaterial(flag, title, callback) {
        this.CommonChoice(1095, 538, title, '/master/material/choice.html?flag=' + flag, callback);
    }
    // 选择所属目录
    DoChoiceCatalogue(url, title, callback) {
        this.CommonChoice(285, 478, title, url, callback);
    }
    // 选择产品计划（为了选择合同号）
    DoChoiceMps(flag, title, callback) {
        this.CommonChoice(1095, 538, title, '/trade/master_production_schedule/choice.html?flag=' + flag, callback);
    }
    // 选择产品计划明细
    DoChoiceMpsLines(flag, headerId, title, callback) {
        this.CommonChoice(1295, 538, title, '/trade/master_production_schedule/lines/choice.html?flag=' + flag + '&mpsId=' + headerId, callback);
    }
    // 选择生产指示书
    DoChoiceMo(flag, title, callback) {
        this.CommonChoice(1095, 538, title, '/trade/production_instruction/choice.html?flag=' + flag, callback);
    }
    // 选择发货发令单
    DoChoiceDo(flag, title, callback) {
        this.CommonChoice(1295, 538, title, '/trade/delivery_command_sheet/choice.html?flag=' + flag, callback);
    }
    // 选择发货发令单明细
    DoChoiceDoLines(flag, headerId, styleNo, title, callback) {
        this.CommonChoice(1295, 538, title,
                '/trade/delivery_command_sheet/lines/choice.html?flag=' + flag + '&headerId=' + headerId + '&styleNo=' + styleNo,
                callback);
    }
    // 选择单耗明细
    DoChoiceBomLines(flag, typeflag, title, callback) {
        this.CommonChoice(1295, 538, title, '/tech/piece_yardage_onesize/choice.html?flag=' + flag + '&typeflag=' + typeflag, callback);
    }
    // 选择产品明细
    DoChoiceProductBom(flag, title, callback) {
        this.CommonChoice(1295, 538, title, '/tech/product_bom/choice.html?flag=' + flag, callback);
    }
    // 选择补料单（为了引入类似款号的补料单）
    DoChoiceMrpFeeding(flag, title, callback) {
        this.CommonChoice(1095, 538, title, '/tech/mrp_feeding_for_import/choice.html?flag=' + flag, callback);
    }
    // 选择成本预测
    DoChoiceCostForecast(flag, title, callback) {
        this.CommonChoice(1295, 538, title, '/tech/cost_forecast/choice.html?flag=' + flag, callback);
    }
    // 选择任务用户组
    DoChoiceTaskUserGroup(flag, title, callback) {
        this.CommonChoice(1095, 538, title, '/workflow/task_role/choice.html?flag=' + flag, callback);
    }
    // 选择加工合同
    DoChoiceProcessingContract(flag, title, callback) {
        this.CommonChoice(1295, 538, title, '/manufacture/cpc/choice.html?flag=' + flag, callback);
    }
    // 选择领料单
    DoChoiceRequisitionSlip(flag, title, callback) {
        this.CommonChoice(1295, 538, title, '/manufacture/requisition_slip/choice.html?flag=' + flag, callback);
    }
    // 选择到货对账
    DoChoiceAccountPayable(flag, title, callback) {
        this.CommonChoice(1295, 538, title, '/purchase/notes_payabled/account_payable/choice.html?flag=' + flag, callback);
    }
    // 选择采购订单
    DoChoicePo(flag, title, callback) {
        this.CommonChoice(1340, 538, title, '/purchase/po/choice.html?flag=' + flag, callback);
    }
}
